home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / pibt3sp3.arc / READCTRL.PAS < prev    next >
Pascal/Delphi Source File  |  1985-07-25  |  3KB  |  62 lines

  1. (*----------------------------------------------------------------------*)
  2. (*         Read_Ctrls --- Fix up ctrl key definitions in string         *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. FUNCTION Read_Ctrls( S : AnyStr ) : AnyStr;
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*     Function:   Read_Ctrls                                           *)
  10. (*                                                                      *)
  11. (*     Purpose:    Convert control sequences in strings.                *)
  12. (*                                                                      *)
  13. (*     Calling Sequence:                                                *)
  14. (*                                                                      *)
  15. (*        Fixed_S := Read_Ctrls( S: AnyStr ) : AnyStr;                  *)
  16. (*                                                                      *)
  17. (*           S       --- the string with potential ctrl seqs to convert *)
  18. (*           Fixed_S --- fixed up string                                *)
  19. (*                                                                      *)
  20. (*     Remarks:                                                         *)
  21. (*                                                                      *)
  22. (*        This routine replaces a character sequence of the form        *)
  23. (*        '^G' -- ascii 94 + ascii 71 -- with the single control        *)
  24. (*        character ctrl-G -- ascii 07.  The actual '^' character       *)
  25. (*        is the global parameter FK_Ctrl_Mark and can be set with      *)
  26. (*        a configuration file.                                         *)
  27. (*                                                                      *)
  28. (*----------------------------------------------------------------------*)
  29.  
  30. VAR
  31.    T: AnyStr;
  32.    I: INTEGER;
  33.    L: INTEGER;
  34.  
  35. BEGIN (* Read_Ctrls *)
  36.                                    (* Scan for ctrl markers *)
  37.    T := '';
  38.    I := 1;
  39.    L := LENGTH( S );
  40.  
  41.    WHILE( I <= L ) DO
  42.       BEGIN                        (* Ctrl marker -- convert next char *)
  43.                                    (* to control character             *)
  44.  
  45.          IF S[I] = FK_Ctrl_Mark THEN
  46.             BEGIN
  47.                I := I + 1;
  48.                T := T + CHR( ORD( S[I] ) - 64 );
  49.                I := I + 1;
  50.             END
  51.          ELSE
  52.             BEGIN                  (* Regular character -- just copy *)
  53.                T := T + S[I];
  54.                I := I + 1;
  55.             END;
  56.  
  57.       END;
  58.  
  59.    Read_Ctrls := T;
  60.  
  61. END   (* Read_Ctrls *);
  62.